EXECUTE msdb.dbo.sysmail_help_profile_sp


EXEC msdb.dbo.sp_send_dbmail
    @profile_name = 'ME.com',
    @recipients = 'ychoi@farmerbros.com',
    @body = 'The Distribution List',
    @subject = 'Distribution Count',
    @execute_query_database ='distribution',
    @query='select RTRIM(a.article) as [Article Name], c.article_id as [Article ID],count(c.article_id) as [number of changes to be Processed]
from MSrepl_commands c, MSarticles a
where c.article_id = a.article_id
group by a.article, c.article_id
order by [number of changes to be Processed] DESC',
	@query_result_width = 512,
	@attach_query_result_as_file=0   ;
    

EXEC msdb.dbo.sp_send_dbmail
    @profile_name = 'FarmerSMTP',
    @recipients = 'ychoi@farmerbros.com',
    @body = 'The stored procedure finished successfully.',
    @subject = 'Automated Success Message' ;




EXECUTE msdb.dbo.sysmail_delete_log_sp
    @logged_before = 'November 3, 2011' ;
go